package com.security.springsecuritylearn02.controller;

import com.security.springsecuritylearn02.entity.Login;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author llj
 * @create 2022-06-28 14:18
 */
@Controller
public class HelloController {

    @RequestMapping("/hello")
    @ResponseBody
    public String hello(){
        return "hello";
    }

    @RequestMapping(value = "/showLogin",method = RequestMethod.GET)
    public String login(){
        return "login";
    }

    @RequestMapping(value = "/userLogin",method = RequestMethod.POST)
    public String userLogin(Login login,Model model){
        System.out.println("========");
        System.out.println(login.getUsername());
        model.addAttribute("name",login.getUsername());
        return "userLogin";
    }

    @RequestMapping(value = "/admin",method = RequestMethod.GET)
    public String admin(){
        System.out.println("admin");
        return "admin";
    }


    @RequestMapping(value = "/user",method = RequestMethod.GET)
    public void user(){
        System.out.println("user");
    }

}
